package cn.wolfcode.trip.admin.controller;


import cn.wolfcode.trip.base.domain.StrategyCatalog;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.query.StrategyCatalogQueryObject;
import cn.wolfcode.trip.base.service.IRegionService;
import cn.wolfcode.trip.base.service.IStrategyCatalogService;
import cn.wolfcode.trip.base.service.IStrategyService;
import cn.wolfcode.trip.base.util.UploadUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;

@Controller
@RequestMapping("/strategyCatalog")
public class StrategyCatalogController {

    @Autowired
    private IStrategyCatalogService strategyCatalogService;
    @Autowired
    private IStrategyService strategyService;

    @RequestMapping("/list")
    public String list(@ModelAttribute("qo") StrategyCatalogQueryObject qo, Model model) {
        //根据攻略和序列排序
        qo.setOrderBy("sc.strategy_id,sc.sequence");
        model.addAttribute("result", strategyCatalogService.queryForList(qo));
        model.addAttribute("strategies", strategyService.listEnable());
        return "strategyCatalog/list";
    }

    @RequestMapping("/saveOrUpdate")
    public String saveOrUpdate(StrategyCatalog strategyCatalog) {
        strategyCatalogService.saveOrUpdate(strategyCatalog);
        return "redirect:/strategyCatalog/list.do";
    }


}
